<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>商品表修改</title>

	<link rel="stylesheet" href="__STATIC__/Bootstrap/Css/bootstrap.min.css" />
	<link rel="stylesheet" href="__STATIC__/Admin/Css/common.css" />
	<script type="text/javascript" src="__STATIC__/uploadify/jquery-1.8.2.min.js"></script>
	<script type="text/javascript">
		//声明这个变量  把ajax地址址传出去调用
		var attr_url='{|U:"ajaxAttr"}';
		
	</script>
	<script type="text/javascript" src='__STATIC__/Admin/Js/goods.js'></script>
	<!--百度编辑器载入的文件-->
		<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/ueditor.all.min.js"> </script>
		<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
		<!--上传插件uploadify的文件-->
		<!--如果用的时候放一个jq-->
		<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
		<link href="__STATIC__/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>
	
	
</head>
<body>
	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">

	<form action="" method='post' enctype="multipart/form-data">
		
			<legend>修改商品</legend>
			<table class='table table-bordered table-hover'>
				<thead>
					<tr>
						<th colspan="2" class="btn btn-primary">基本信息</th>
					</tr>
				</thead>
				<tbody>
					<tr class="info">
						<td>所属分类</td>
						<td>
							<select name="cid">
								<option value="0">-请选择-</option>
								<foreach from="$CateData" key="$k" value="$v">
									<option value="{$v.cid}" pid="{$v.pid}" tid="{$v.tid}" <if value="$oldData['cid']==$v['cid']">selected</if> >{$v._name}</option>
								</foreach>
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>所属品牌</td>
						<td>
							<select name="bid">
								<option value="0">-请选择-</option>
								<foreach from="$BraData" key="$k" value="$v">
									<option value="{$v.bid}" <if value="$oldData['bid']==$v['bid']">selected</if>>{$v.bname}</option>
								</foreach>
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>商品名称</td>
						<td>
							<input type="text" name='gname' value="{$oldData.gname}"/>
							
						</td>
					</tr>
					<tr class="info">
						<td>单位</td>
						<td>
							<input type="text" name='unit' value="{$oldData.unit}"/>
						</td>
					</tr>
					<tr class="info">
						<td>市价场</td>
						<td>
							<input type="text" name='marketprice' value="{$oldData.marketprice}"/>
						</td>
					</tr>
					<tr class="info">
						<td>商城价</td>
						<td>
							<input type="text" name='shopprice' value="{$oldData.shopprice}"/>
						</td>
					</tr>
					<tr class="info">
						<td>点击次数</td>
						<td>
							<input type="text" name='click' value="{$oldData.click}" />
						</td>
					</tr>
				</tbody>
			</table>

			<p class="btn btn-primary">商品属性</p>
			
			<table class="table table-bordered table-hover" id='attr' class="info">
			<foreach from="$oldType" key="$k" value="$v">
				<if value="!$v['taclass']">
					<tr class="info">
						<td align="right">{$v.taname}</td>
						<td>
							<select name="attr[{$v.taid}][tavalue][]">
								<option value="0">-请选择-</option>
								<foreach from="$v.tavalue" key="$kk" value="$vv">
									<option value="{$vv}" <if value="$v['gtvalue']==$vv">selected=""</if> >{$vv}</option>
								</foreach>
							</select>
						</td>
					</tr>
				</if>
			</foreach>
		<!--没有被选则的循环-->
			<foreach from="$attr_no" key="$k" value="$v">
				<tr class="info">
					<td align="right">{$v.taname}</td>
					<td>
						<select name="attr[{$v.taid}][tavalue][]">
							<option value="0">-请选择-</option>
							<foreach from="$v.tavalue" key="$kk" value="$vv">
								<option value="{$vv}" >{$vv}</option>
							</foreach>
						</select>
					</td>
				</tr>
			</foreach>
			</table>
			<p class="btn btn-primary">商品规格</p>
			<table class="table table-bordered table-hover" id='spec'>
				<foreach from="$oldType" key="$k" value="$v">
					<if value="$v['taclass']">
						<tr class="info">
							<td align="right">{$v.taname}</td>
							<td>
								<select name="spec[{$v.taid}][tavalue][]">
									<option value="0">-请选择-</option>
									<foreach from="$v.tavalue" key="$kk" value="$vv">
										<option value="{$vv}" <if value="$v['gtvalue']==$vv">selected=""</if> >{$vv}</option>
									</foreach>
								</select>
							</td>
							<td>
								附加价格 
								<input name="spec[{$v.taid}][added][]" type="text" value="{$v.added}" >
							</td>
							<td>
								<span class="add-spec btn btn-success"><i class="icon-plus icon-white"></i>添加规格</span>
								<span class="del-spec btn btn-info"><i class="icon-white icon-minus"></i>删除规格</span>
							</td>
						</tr>
					</if>
				</foreach>
				<!--没有被选则的循环-->
				<foreach from="$spec_no" key="$k" value="$v">
						<tr class="info">
							<td align="right">{$v.taname}</td>
							<td>
								<select name="spec[{$v.taid}][tavalue][]">
									<option value="0">-请选择-</option>
									<foreach from="$v.tavalue" key="$kk" value="$vv">
										<option value="{$vv}">{$vv}</option>
									</foreach>
								</select>
							</td>
							<td>
								附加价格 
								<input name="spec[{$v.taid}][added][]" type="text" value="" >
							</td>
							<td>
								<span class="add-spec btn btn-success"><i class="icon-plus icon-white"></i>添加规格</span>
								<span class="del-spec btn btn-info"><i class="icon-white icon-minus"></i>删除规格</span>
							</td>
						</tr>
				</foreach>
				
			
				
				
			</table>

			<table class='table table-bordered'>
				<tr>
					<th colspan="3" class="btn btn-primary">列表图</th>
				</tr>
				<tr class="info">
					<td>上传列表图片</td>
					<td>
						<input type="file" name='listpic' id='listpic'/>
					</td>
					<td id='pic-list'>
						<img src="__ROOT__/{$oldData.listpic}" alt="" />
						<input type="hidden" name="listpic" value="{$oldData.listpic}" />
					</td>
				</tr>
			</table>

			<table class='table table-bordered'>
				<tr>
					<th colspan="3" class="btn btn-primary">商品图册</th>
				</tr>
				<tr class="info">
					<td>上传图片</td>
					<td>
						<input type="file" name='thumb[]' id='thumb' />
					</td>
					<td id='thumb-list'>
						<foreach from="$oldData['thumb']" key="$k" value="$v">
							<img src="__ROOT__/{$v}" width="100" alt="" />
							<input type="hidden" name="thumb[]" value="{$v}" />
						</foreach>
					</td>
					<!--放修改的图片-->
					<td id='thumbs'></td>
					
				
				</tr>
			</table>

			<table class='table'>
				<tr class="next_show">
					<th class="btn btn-primary">商品详细</th>
				</tr>
				<tr class="hide info">
					<td>
					<script id="editor" type="text/plain" style="width:1024px;height:200px;" name="intro">{$oldData.intro}</script>
	    		<script>
	        		var ue = UE.getEditor('editor');
	    		</script>
					</td>
				</tr>
			</table>

			<table class='table'>
				<tr class="next_show">
					<th class="btn btn-primary">售后服务</th>
				</tr>
				<tr class="hide info">
					<td>
						<script id="editor1" type="text/plain" style="width:1024px;height:200px;" name="service">{$oldData.service}</script>
	    		<script>
	        		var ue = UE.getEditor('editor1');
	    		</script>
					</td>
				</tr>
			</table>
			<br />
			<input type="hidden" name="gid" id="gid" value="{$hd.get.gid}" />
			<input type="submit" value="修改成功" class="btn btn-primary btn-block btn-large" />
		
	</form>

	</div>
	</div>
	</div>

<!--这是列表图的js-->
<script type="text/javascript">
        $('#listpic').uploadify({
            'formData'     : {
            	//POST数据
                '<?php echo session_name();?>' : '<?php echo session_id();?>',
            },
            'fileTypeDesc' : '上传文件',
            //上传描述
            'fileTypeExts' : '*.jpg;*.png',
            'swf'      : '__STATIC__/uploadify/uploadify.swf',
            'uploader' : '{|U:"upload"}',
            'buttonText':'选择文件',
            'fileSizeLimit' : '2000KB', //上传文大小
            'uploadLimit' : 1,//上传文件数
            'width':65,
            'height':25,
            //是否多文件上传
            'multi':false,
            'successTimeout':10,
            //等待服务器响应时间
            'removeTimeout' : 0.2,
            //成功显示时间
            'onUploadSuccess' : function(file, data, response) {
            	//把变量转为json
                data=$.parseJSON(data);
                img = '<img src="'+data.url + '" width="100" height="100" />';
			  	img += '<input type="hidden" name="listpic" value="' +data.path+ '"/>';
                $('#pic-list').empty().append(img);
             
            }
        });
</script>

<!--这是大图的js-->
<script type="text/javascript">
        $('#thumb').uploadify({
            'formData'     : {
            	//POST数据
                '<?php echo session_name();?>' : '<?php echo session_id();?>',
            },
            'fileTypeDesc' : '上传文件',
            //上传描述
            'fileTypeExts' : '*.jpg;*.png',
            'swf'      : '__STATIC__/uploadify/uploadify.swf',
            'uploader' : '{|U:"upload_img"}',
            'buttonText':'选择文件',
            'fileSizeLimit' : '2000KB', //上传文大小
            'uploadLimit' : 1000,//上传文件数
            'width':65,
            'height':25,
            //是否多文件上传
            'multi':true,
            'successTimeout':10,
            //等待服务器响应时间
            'removeTimeout' : 0.2,
            //成功显示时间
            'onUploadSuccess' : function(file, data, response) {
            	//放修改的图片的地方
            	$('#thumb-list').html('');
            	//把变量转为json
                data=$.parseJSON(data);
                div = '<div style="float:left">';
                div += '<img src="'+ data.url + '" width="100" height="100" />';
    			div += '<input type="hidden" name="thumb[]" value="' + data.path + '"/>';
                $('#thumbs').append(div);
            }
        });
  
    
</script>
</body>
</html>